var Common = Common || {};
Common['getRequest'] = function() {
	var url = location.search;
	// 获取url中"?"符后的字串
	var theRequest = new Object();
	if (url.indexOf("?") != -1) {
		var str = url.substr(1);
		strs = str.split("&");
		for ( var i = 0; i < strs.length; i++) {
			theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
		}
	}
	return theRequest;
};
Common['formatTime'] = function(time){
	var d = new Date(time);
	var h = d.getHours();
	var m = d.getMinutes();
	return (h>9?h:'0'+h)+':'+(m>9?m:'0'+m);
};

function parseDay(date){
	if(date.toString().length == 1)
		return "0".concat(date);
	else
		return date;
}

/**
 * 转换货币类型
 * @param value
 * @returns
 */
function numFormat(value){
	var p = value.toString();
	if(p == "0")
		return "0.00";
	if(p.length == 2)
		p = "0" + p;
	p = p.substr(0, p.length - 2) + '.' + p.substr(p.length - 2, p.length);
	return p;
}

/**
 * 将输入框中的字符串转化成以分为单位
 */
function moneyFormat(value){
	var p = value.toString();
	if(p == "0.00")
		return 0;
	p  = p.substr(0, p.length - 3) + p.substr(p.length - 2, p.length);
	return p;
}

/**
 * 转换成时间格式输出
 * @param time
 */
function parseTime(time){
	var date = new Date(time);
	var outDate = date.getFullYear() + '-' + 
			parseDay(date.getMonth() + 1 ) + '-' + 
			parseDay(date.getDate()) + " " +
			parseDay(date.getHours()) + ":" +
			parseDay(date.getMinutes()) + ":" +
			parseDay(date.getSeconds());
	return outDate;
}

/**
 * 首字母转换成大写
 * @param str
 */
function toHeadUpperCase(str){
	var p = str.toString().substr(0, 1);
	return p.toUpperCase() + str.toString().substr(1, str.length);
}

function getPrice(price){
	var price = price.substr(0, price.length - 2) + '.' + price.substr(price.length - 2, price.length);
	return price;
}